#coding:utf-8
import sql
db=sql.Mysql('127.0.0.1','root','123456','test',3306)
def test():
    res=db.read('select * from dls')
    print(res)
    return res

def dbs(args1,args2):
    for i in args1:
        if i['pid']==args2:
            print(i)
            tt[i['id']]=i['name']
            if i['cid']:
                dbs(args1,i['id'])

if __name__=="__main__":
    tt={}
    res=test()
    dbs(res,1)
    print(tt)
    #18062253692
    # for i in res:
    #     if i['pid'] == 2:
    #         print(i['id'], i)
    #         for n in res:
    #             if n['pid'] == i['id']:
    #                 print

